package com.evaluationsystem.system.controller;

import com.evaluationsystem.system.serivce.AppraisalService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("appraisal")
@Api(value = "考题录入CRUD接口 ，2020-4-16，gdy")
public class AppraisalController {

    @Autowired
    AppraisalService service;

    @GetMapping("")
    @ApiOperation("考题录入页面跳转接口")
    public String appraisalHtml(){
        return "system/appraisal/appraisal";
    }

    @GetMapping("appraisalAddHtml")
    @ApiOperation("考题新增页面跳转接口")
    public String appraisalAddHtml(){
        return "system/appraisal/appraisalAdd";
    }

    @GetMapping("appraisalUpdataHtml/{vappraisalsid}")
    @ApiOperation("考题修改页面跳转接口")
    @ApiImplicitParam(name = "vappraisalsid",value = "考题信息主键ID",required = true)
    public String appraisalUpdataHtml(@PathVariable("vappraisalsid") String vappraisalsid,Map<Object,Object> map){
        map.put("vappraisalsid",vappraisalsid);
        return "system/appraisal/appraisalUpdata";
    }

    @GetMapping("appraisalLookHtml/{vappraisalsid}")
    @ApiOperation("考题标准(答案)页面跳转接口")
    @ApiImplicitParam(name = "vappraisalsid",value = "考题信息主键ID",required = true)
    public String appraisalLookHtml(@PathVariable("vappraisalsid") String vappraisalsid,Map<Object,Object> map){
        map.put("vappraisalsid",vappraisalsid);
        return "system/appraisal/appraisalLook";
    }

    @ResponseBody
    @ApiOperation(value = "select 下拉列表数据加载 接口",notes = "gdy")
    @PostMapping("appraisalSelectDatas")
    public Map<String,Object> appraisalSelectDatas(){
        Map<String,Object> res = service.appraisalSelectDatas();
        return res;
    }

    @ResponseBody
    @ApiOperation(value = "考题 Table 数据加载 接口",notes = "gdy")
    @ApiImplicitParams({
            @ApiImplicitParam(name="page",value="第几页",required=true,paramType="form"),
            @ApiImplicitParam(name="limit",value="要查询多少条数据",required=true,paramType="form"),
            @ApiImplicitParam(name="vcontent",value="筛选条件,评定内容",paramType="form"),
            @ApiImplicitParam(name="vappraisalsflg",value="筛选条件,评定类型",paramType="form"),
            @ApiImplicitParam(name="vassessflg",value="筛选条件,考核类别",paramType="form")
    })
    @PostMapping("appraisalTableDatas")
    public Map<String,Object> appraisalTableDatas(@RequestBody Map<String,Object> param){
        System.out.println(param);
        Map<String,Object> res = service.appraisalTableDatas(param);
        return res;
    }

    @ResponseBody
    @ApiOperation(value = "考题新增接口",notes = "")
    @ApiImplicitParam(name="param",value="{field:vcontent-评定内容,vassessflg-评定类型,vappraisalsflg-考核类别,scoreinfos:vno-NO,vstandard-标准,iscore-分值}",required=true,paramType="json")
    @PostMapping("appraisalAdd")
    public Map<String,Object> appraisalAdd(@RequestBody Map<String,Object> param){
        Map<String,Object> res = service.appraisalAdd(param);
        return res;
    }

    @ResponseBody
    @ApiOperation(value = "考题修改接口",notes = "")
    @ApiImplicitParam(name="param",value="{field:vcontent-评定内容,vassessflg-评定类型,vappraisalsflg-考核类别,scoreinfos:vno-NO,vstandard-标准,iscore-分值:过滤掉老数据,新增新的答案和分值}",required=true,paramType="json")
    @PostMapping("appraisaUpdata")
    public Map<String,Object> appraisaUpdata(@RequestBody Map<String,Object> param){
        Map<String,Object> res = service.appraisaUpdata(param);
        return res;
    }


    @ResponseBody
    @ApiOperation(value = "考题 启用/禁用 修改接口",notes = "")
    @ApiImplicitParam(name="param",value="{vdelflg-启用禁用标记-0启用-1禁用,vappraisalsid-考题主键ID,startAndForbid-是禁用请求还是启用请求}",required=true,paramType="json")
    @PostMapping("appraisalStartAndForbid")
    public Map<String,Object> appraisalStartAndForbid(@RequestBody Map<String,Object> param){
        Map<String,Object> res = service.appraisalStartAndForbid(param);
        return res;
    }

    @ResponseBody
    @ApiOperation(value = "查看 考题答案 Table 数据加载 接口 ",notes = "")
    @ApiImplicitParam(name="param",value="{vappraisalsid-考题主键ID}",required=true,paramType="json")
    @PostMapping("scoreinfoTableDatas")
    public Map<String,Object> scoreinfoTableDatas(@RequestBody Map<String,Object> param){
        Map<String,Object> res = service.scoreinfoTableDatas(param);
        return res;
    }



    @ResponseBody
    @ApiOperation(value = "根据 考题主键查询考题和答案 ",notes = "")
    @ApiImplicitParam(name="param",value="{vappraisalsid-考题主键ID}",required=true,paramType="json")
    @PostMapping("appraisalAndScoreinfos")
    public Map<String,Object> appraisalAndScoreinfos(@RequestBody Map<String,Object> param){
        Map<String,Object> res = service.appraisalAndScoreinfos(param);
        return res;
    }

    @ResponseBody
    @ApiOperation(value = "标准(答案) 启用/禁用 修改接口",notes = "")
    @ApiImplicitParam(name="param",value="{vdelflg-启用禁用标记-0启用-1禁用,vappraisalsid-考题主键ID,vno-答案序号id,startAndForbid-是禁用请求还是启用请求}",required=true,paramType="json")
    @PostMapping("scoreinfoStartAndForbid")
    public Map<String,Object> scoreinfoStartAndForbid(@RequestBody Map<String,Object> param){
        Map<String,Object> res = service.scoreinfoStartAndForbid(param);
        return res;
    }


    @ResponseBody
    @ApiOperation(value = "标准(答案)/分值 修改接口",notes = "")
    @ApiImplicitParam(name="param",value="{vappraisalsid:主键ID,vno:序号,vstandard:答案,iscore:分值}",required=true,paramType="json")
    @PostMapping("standardAndIscoreUpdata")
    public Map<String,Object> standardAndIscoreUpdata(@RequestBody Map<String,Object> param){
        Map<String,Object> res = service.standardAndIscoreUpdata(param);
        return res;
    }

}
